* **************************************************************************** *
* Sierra Leone - Social Signaling and Childhood Immunization
* The Effect of Signals on Knowledge about Vaccination Decisions
* **************************************************************************** *
/*
** Purpose:     The Effect of Signals on Knowledge about Vaccination Decisions
*/
* **************************************************************************** *
* **************************************************************************** *

  * ----------------------------------------------------------------------------
  * First- and Second-Order Beliefs - with Controls

    * Load First-Order beliefs:
    use  "${Replicate_SocialSignals_dtaInter}/FirstOrderBeliefs_Data.dta", clear

	* Append Second-Order Beliefs:
	append using "${Replicate_SocialSignals_dtaInter}/SecondOrderBeliefs_Data.dta", gen(SecondOrder_Beliefs)

	* Set locals with controls:
	local FO_ANC_107             = " anc2_first_107_dm  anc3_first_107_dm  anc4_first_107_dm "
	local FO_ANC_274             = " anc2_first_274_dm  anc3_first_274_dm  anc4_first_274_dm "


	local FO_Mother_Controls_107 = " mother_age_w01_first_107_dm edu2_first_107_dm edu3_first_107_dm farm_first_107_dm  birth2_first_107_dm birth3_first_107_dm birth4_first_107_dm birth5_first_107_dm "
	local FO_Controls_107        = " age_u1_dm relate_first_107_dm"

	local FO_Mother_Controls_274 = " mother_age_w01_first_274_dm edu2_first_274_dm edu3_first_274_dm farm_first_274_dm  birth2_first_274_dm birth3_first_274_dm birth4_first_274_dm birth5_first_274_dm "
	local FO_Controls_274        = " age_u1_dm_9mo relate_first_274_dm "


	local SO_Mother_Controls_107 = " mother_age_w01_second_107_dm edu2_second_107_dm edu3_second_107_dm farm_second_107_dm  birth2_second_107_dm birth3_second_107_dm birth4_second_107_dm birth5_second_107_dm "
	local SO_Controls_107        = " age_dm relate_second_107_dm "

	local SO_Mother_Controls_274 = " mother_age_w01_second_274_dm edu2_second_274_dm edu3_second_274_dm farm_second_274_dm  birth2_second_274_dm birth3_second_274_dm birth4_second_274_dm birth5_second_274_dm "
	local SO_Controls_274        = " age_dm_9mo relate_second_274_dm"


	local SO_ANC_107             = " anc2_second_107_dm anc3_second_107_dm anc4_second_107_dm "
	local SO_ANC_274             = " anc2_second_274_dm anc3_second_274_dm anc4_second_274_dm "


	summ  correct_vacc  treat3 treat4 treat2    `FO_Mother_Controls_107'  `FO_Controls_107'  `FO_ANC_107'       if age_u1>= 107 & age_u1< 274

	summ  correct_vacc  treat3 treat4 treat2    `FO_Mother_Controls_274'  `FO_Controls_274'   `FO_ANC_274'      if age_u1>=274 & age_u1<=365

	summ  secondorder   treat3 treat4 treat2    `SO_Mother_Controls_107'  `SO_Controls_107'   `SO_ANC_107'      if age_pikin>=107 & age_pikin< 274

	summ  secondorder   treat3 treat4 treat2    `SO_Mother_Controls_274'  `SO_Controls_274'   `SO_ANC_274'      if age_pikin>=274  & age_pikin<=365



	** First Order beliefs
	eststo clear
	areg     correct_vacc  treat3 treat4 treat2    `FO_Mother_Controls_107'  `FO_Controls_107'  `FO_ANC_107'     if age_u1>= 107 & age_u1< 274, absorb(strata) vce(bootstrap , reps(${RepsNum}) seed(${seed}) cluster(clinic))
	eststo
	test   treat3 = treat2
	estadd scalar treat2_treat3 = r(p)
	test   treat3 = treat4
	estadd scalar treat3_treat4 = r(p)
	test   treat2 = treat4
	estadd scalar treat2_treat4 = r(p)
	test   treat2 treat3 treat4
	estadd scalar bracelets     = r(p)
	estadd local Obs            = "`e(N)'"
	estadd scalar C_mean        = _b[_cons]
	estadd local controls     "Yes"
	estadd local age_group    "3.5-12"
	eststo model_firstbelief_35mo


	areg     correct_vacc  treat3 treat4 treat2    `FO_Mother_Controls_274'  `FO_Controls_274'   `FO_ANC_274'      if age_u1>=274 & age_u1<=365, absorb(strata) vce(bootstrap, reps(${RepsNum}) seed(${seed}) cluster(clinic))
	eststo
	test   treat3 = treat2
	estadd scalar treat2_treat3 = r(p)
	test   treat3 = treat4
	estadd scalar treat3_treat4 = r(p)
	test   treat2 = treat4
	estadd scalar treat2_treat4 = r(p)
	test   treat2 treat3 treat4
	estadd scalar bracelets     = r(p)
	estadd local Obs            = "`e(N)'"
	estadd scalar C_mean        = _b[_cons]
	estadd local controls     "Yes"
	estadd local age_group    "9-12"
	eststo model_firstbelief_9mo

	* --------------------------------------------------------------------------
	* Second-Order Beliefs:
	areg     secondorder   treat3 treat4 treat2       `SO_Mother_Controls_107'  `SO_Controls_107'   `SO_ANC_107'      if age_pikin>=107 & age_pikin< 274, absorb(strata) vce(bootstrap, reps(${RepsNum}) seed(${seed}) cluster(clinic))
	eststo
	test   treat2 = treat3
	estadd scalar treat2_treat3 = r(p)
	test   treat2 = treat4
	estadd scalar treat2_treat4 = r(p)
	test   treat3 = treat4
	estadd scalar treat3_treat4 = r(p)
	test   treat2 treat3 treat4
	estadd scalar bracelets     = r(p)
	estadd local Obs            = "`e(N)'"
	estadd scalar C_mean        = _b[_cons]
	estadd local controls     "Yes"
	estadd local age_group    "3.5-12"
	eststo model_secondbelief_35mo


	areg     secondorder  treat3 treat4 treat2         `SO_Mother_Controls_274'  `SO_Controls_274'   `SO_ANC_274'          if age_pikin>=274  & age_pikin<=365 , absorb(strata) vce(bootstrap, reps(${RepsNum}) seed(${seed}) cluster(clinic))
	eststo
	test   treat2 = treat3
	estadd scalar treat2_treat3 = r(p)
	test   treat2 = treat4
	estadd scalar treat2_treat4 = r(p)
	test   treat3 = treat4
	estadd scalar treat3_treat4 = r(p)
	test   treat2 treat3 treat4
	estadd scalar bracelets     = r(p)
	estadd local Obs            = "`e(N)'"
	estadd scalar C_mean        = _b[_cons]
	estadd local controls     "Yes"
	estadd local age_group    "9-12"
	eststo model_secondbelief_9mo

	esttab  ///
	model_secondbelief_35mo  model_secondbelief_9mo    ///
	model_firstbelief_35mo   model_firstbelief_9mo    ///
	using "${Replicate_SocialSignals_Tables}/Table_FirstSecondOrderBeliefs_raw.tex", ///
	prehead("\begin{tabular}{l*{5}{c}} \toprule \\"                     ///
	"\multicolumn{1}{l}{\textbf{Dependent variable:}} & \multicolumn{2}{c}{\textbf{Others know \# of}}                  & \multicolumn{2}{c}{\textbf{Know \# of}}  \\"           ///
	"                                                 & \multicolumn{2}{c}{\textbf{vaccines of own child}}   & \multicolumn{2}{c}{\textbf{vaccines of other children}} \\"        ///
	"\multicolumn{1}{l}{Age in months}                & \multicolumn{1}{c}{3.5-9 months}  & \multicolumn{1}{c}{9-12 months}  & \multicolumn{1}{c}{3.5-9 months} & \multicolumn{1}{c}{9-12 months} \\")   ///
	scalars("C_mean         Control Group mean"                         ///
	"Obs            Observations"                               ///
	"treat2_treat3  \(S_{4}\) \(>\) 0: p(UI = S4)"              ///
	"treat2_treat4  \(S_{5}\) \(>\) 0: p(UI = S5)"              ///
	"treat3_treat4  p(S4 = S5)"                                 ///
	"bracelets      Joint F-Test"                               ///
	"controls       Controls"            )                      ///
	substitute(\(S\_{4}\) \(S_{4}\)  \(S\_{5}\) \(S_{5}\))              ///
	keep(_cons treat3 treat4 treat2)                                    ///
	varlabels(_cons "Control Group mean")                               ///
	sfmt(3) ${StarsOpt}   nomtitles                                     ///
	addnotes("") label b(3) se(3)  nobaselevels noconstant noobs        ///
	nolines posthead(\midrule) postfoot("\bottomrule \end{tabular}") tex  ///
	replace

	filefilter "${Replicate_SocialSignals_Tables}/Table_FirstSecondOrderBeliefs_raw.tex"      ///
	"${Replicate_SocialSignals_Tables}/Table_FirstSecondOrderBeliefs_Controls.tex", from("[1em]") to(" ") replace
	erase	     "${Replicate_SocialSignals_Tables}/Table_FirstSecondOrderBeliefs_raw.tex"


	* ----------------------------------------------------------------------------
	* outsheet p-values, with controls

	esttab  ///
	model_secondbelief_35mo  model_secondbelief_9mo    ///
	model_firstbelief_35mo   model_firstbelief_9mo    ///
	using "${Replicate_SocialSignals_Tables}/Table_FirstSecondOrderBeliefs_raw.tex", ///
	prehead("\begin{tabular}{l*{5}{c}} \toprule \\"                     ///
	"\multicolumn{1}{l}{\textbf{Dependent variable:}} & \multicolumn{2}{c}{\textbf{Others know \# of}}                  & \multicolumn{2}{c}{\textbf{Know \# of}}  \\"           ///
	"                                                 & \multicolumn{2}{c}{\textbf{vaccines of own child}}   & \multicolumn{2}{c}{\textbf{vaccines of other children}} \\"        ///
	"\multicolumn{1}{l}{Age in months}                & \multicolumn{1}{c}{3.5-9 months}  & \multicolumn{1}{c}{9-12 months}  & \multicolumn{1}{c}{3.5-9 months} & \multicolumn{1}{c}{9-12 months} \\")   ///
	scalars("C_mean         Control Group mean"                         ///
	"Obs            Observations"                               ///
	"treat2_treat3  \(S_{4}\) \(>\) 0: p(UI = S4)"              ///
	"treat2_treat4  \(S_{5}\) \(>\) 0: p(UI = S5)"              ///
	"treat3_treat4  p(S4 = S5)"                                 ///
	"bracelets      Joint F-Test"                               ///
	"controls       Controls"            )                      ///
	substitute(\(S\_{4}\) \(S_{4}\)  \(S\_{5}\) \(S_{5}\))              ///
	keep(_cons treat3 treat4 treat2)                                    ///
	varlabels(_cons "Control Group mean")                               ///
	sfmt(3) ${StarsOpt}   nomtitles                                     ///
	addnotes("") label b(3) p(3)  nobaselevels noconstant noobs         ///
	nolines posthead(\midrule) postfoot("\bottomrule \end{tabular}") tex  ///
	replace

	filefilter "${Replicate_SocialSignals_Tables}/Table_FirstSecondOrderBeliefs_raw.tex"      ///
	"${Replicate_SocialSignals_Tables}/pvalues/Table_FirstSecondOrderBeliefs_Controls_pvals.tex", from("[1em]") to(" ") replace
	erase	     "${Replicate_SocialSignals_Tables}/Table_FirstSecondOrderBeliefs_raw.tex"







********************************************************************************
** End of the Dofile !!!
********************************************************************************
